﻿using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Text;
using System.Collections.Generic;

namespace webnew
{
    public partial class Default : WebPageBase.PageBase
    {
        public string years, months, days, weekdays, truename, rolename,Ver;
        //初始化菜单树对象标识
        int iclasscount = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
           // if (!IsPostBack)
            //{
                years = DateTime.Today.Year.ToString();
                months = DateTime.Today.Month.ToString();
                days = DateTime.Today.Day.ToString();
                weekdays = webnew.Common.CommonHelper.getWeekday(DateTime.Today.DayOfWeek);
                Ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
           // }
        }
        


        /// <summary>
        /// 生成EXT一级菜单
        /// </summary>
        /// <returns></returns>
        public string GetTreeMenu()
        {
            string strMacName = Server.MachineName;
            List<Model.Sys_NavigationInfo> lst = new BLL.Sys_Navigation().GetUserNav(UserInfor.Id, strMacName);//"47244D72-6723-4C67-A8AD-31D81D65B454");           
            StringBuilder strTreeMenu = new StringBuilder();
            foreach (Model.Sys_NavigationInfo item in lst)
            {
                if (item.ParentID == webnew.Common.CommonHelper.GetMenuParentID())  //菜单顶级父节点，通过修改配置文件MenuParentID
                {
                    iclasscount++;
                    //调用ExtTree.ToTreeMenu方法，生成EXT一级菜单栏对象
                    strTreeMenu.Append(ExtMenuTree.ToTreeMenu(item.Id.ToString(), item.picsrc, item.NaviName, iclasscount.ToString()));
                }
            }           
            return strTreeMenu.ToString();
        }



        /// <summary>
        /// 一级菜单绑定到Panel面板上（Ext面板）,注：tree(对应ToTreeMenu方法中生成的tree对象)
        /// </summary>
        /// <returns></returns>
        public string bingTreeToPanel()
        {
            if (iclasscount == 0) return "";
            StringBuilder strtreename = new StringBuilder();            
            for (int y = 1; y <= iclasscount; y++)
            {
                if (y == iclasscount) strtreename.Append("tree" + y.ToString());
                else strtreename.Append("tree" + y.ToString()+",");                
            }
            return strtreename.ToString();
        }
        /// <summary>
        /// 获取当前用户登录IP
        /// </summary>
        /// <returns></returns>
        public string getuserip()
        {
           return new BLL.Sys_Log().GetUserIP(System.Web.HttpContext.Current.Request);
        }
    }
}
